package com.niit;

import com.niit.entity.Category;
import com.niit.mapper.CategoryMapper;
import com.niit.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

public class TestKeys {
    public static void main(String[] args) {

        SqlSession sqlSession = MybatisUtil.getSqlSession();
        CategoryMapper categoryMapper = sqlSession.getMapper(CategoryMapper.class);

        Category category = new Category();
        category.setCname("jv1-分类");
        category.setCdescription("jv1-分类描述");

        categoryMapper.addCategory(category);
        sqlSession.commit();// 提交事务

        // TODO 直接得到cid值，怎么办
        System.out.println(category.getCid());

        // 使用cid完成别的操作/业务逻辑
    }
}
